var listUrl = "rest/parkProductsList.do";
	var couponType;   //优惠券类型
	var ownerType;   //商家或停车场优惠券标识
	var discoutType; //面值类型
	var isDisplay;   //优惠券展示状态
	var isShare;     //是否和其他优惠券共享s
	var pushType;    //推送类型
	var couponState; //优惠券状态
	var parkingNames;
	var textName;
	var unitName;
	$(document).ready(function() {
		parkingNames = syncCouponParkingList();
	});
/*	//获取组织机构名称
	$("#orgId").combobox({
		url:'rest/parkingOrg.do',
		valueField:'id',
		textField:'name',
		loadFilter: function(data){
			var result = data.data.rows;
			return result;
		}
		
	});*/
	//关联查询所有停车场名称
//	function syncCouponParkingList(){
//	var data;
//	$.ajax({
//		type : "post",
//		url : 'rest/searchProductByParkId.do',
//		async : false,
//		success : function(result) {
//			if (result.retCode == '0000') {
//				data=result.data;
//			}
//			else{
//				data="";
//			}
//		}
//	});
//	return data;
//   }
	function getEchartData(data){
		var myChart = echarts.init(document.getElementById('div')); 
		var timeData = new Array();
		var numData = new Array();
		for(var map in data.data){
			timeData.push(data.data[map].regDate);
			numData.push(data.data[map].amount);
		}
		var option = {
//			    title : {
//			        text: textName
//			    },
			    tooltip : {
			        trigger: 'axis'
			    },
			    
			    toolbox: {
			        show : true,
			        feature : {
			            mark : {show: true},
			            dataView : {show: true, readOnly: false},
			            magicType : {show: true, type: ['line', 'bar']},
			            restore : {show: true},
			            saveAsImage : {show: true}
			        }
			    },
			    calculable : true,
			    xAxis : [
			        {
			            type : 'category',
			            boundaryGap : false,
			            data : timeData
			        }
			    ],
			    yAxis : [
			        {
			            type : 'value',
			            axisLabel : {
			                formatter: '{value}'
			            }
			        }
			    ],
			    series : [
			        {
			            name:'最高'+unitName,
			            type:'line',
			            data:numData,
			            markPoint : {
			                data : [
			                    {type : 'max', name: '最大值'}
			                  
			                ]
			            },
			            markLine : {
			                data : [
			                    {type : 'average', name: '平均值'}
			                ]
			            }
			        }
			    ]
			};
		// 为echarts对象加载数据 
        myChart.setOption(option); 
		
	}
	
	//关联查询所有停车场名称
	function syncCouponParkingList(){
	var data;
//	$.ajax({
//		type : "post",
//		url : 'rest/searchProductByParkId.do',
//		async : false,
//		success : function(result) {
//			if (result.retCode == '0000') {
//				data=result.data;
//			}
//			else{
//				data="";
//			}
//		}
//	});
	return data;
   }
	
   function searchReport(memberReport){
	   var url = "";
	   if(memberReport == "memberReport"){
		   url = "rest/memberReport.do";
		   textName = "会员统计分析";
		   unitName = "数量";
	   }else if(memberReport == "parkMerchantReport"){
		   url = "rest/parkMerchantReport.do";
		   textName = "商户统计分析";
		   unitName = "数量";
	   }else if( memberReport == "parkingPayReport"){
		   url = "rest/parkingPayReport.do";
		   textName = "停车交易统计分析";
		   unitName = "总额";
	   }else if( memberReport == "parkingBusinessReport"){
		   url = "rest/parkingPayReport.do?businessType=0";
		   textName = "时租缴费统计分析";
		   unitName = "总额";
	   }else if( memberReport == "parkingBussinessUseReport"){
		   url = "rest/parkingPayReport.do?businessType=4";
		   textName = "车证使用统计分析";
		   unitName = "总额";
	   }else if( memberReport == "parkingSaleUseReport"){
		   url = "rest/parkingAndBussinessUseReport.do?ownerType=1&couponFlag=0";
		   textName = "停车产品使用统计分析";
		   unitName = "总额";
	   }else if( memberReport == "parkingSaleReport"){
		   url = "rest/parkingAndBussinessReceiveReport.do?ownerType=1&couponFlag=0";
		   textName = "停车产品销售统计分析";
		   unitName = "总额";
	   }else if( memberReport == "parkingCouponUseReport"){
		   url = "rest/parkingAndBussinessUseReport.do?ownerType=1&couponFlag=1";
		   textName = "停车券领取使用统计分析";
		   unitName = "总额";
	   }else if( memberReport == "bussinessProductUseReport"){
		   url = "rest/parkingAndBussinessUseReport.do?ownerType=0&couponFlag=0";
		   textName = "商家产品使用统计分析";
		   unitName = "总额";
	   }else if( memberReport == "bussinessCouponUseReport"){
		   url = "rest/parkingAndBussinessUseReport.do?ownerType=0&couponFlag=1";
		   textName = "商家券领取使用统计分析";
		   unitName = "总额";
	   }
	   
	   textName = "";
		$('#fm').form('submit', {
			url : url,
			onSubmit : function() {
			/* 	var validator = $(this).form('validate');
				if (validator) {
					$.messager.progress();
				}
				return validator; */
			},
			success : function(result) {
				$.messager.progress('close');
				var result = eval('(' + result + ')');
				if (result.retCode == '0000') {
					getEchartData(result);

				} else {
					$.messager.show({
						title : 'Error',
						msg : result.retMsg
					});
				}
			}
		});
   }